#include "protocol.h"
#include <QDate>
#include <QSettings>
#include <QtEndian>

QString jdString(int jd)
{
    QDate date(2000, 1, 1);
    return date.addDays(jd - 1).toString("yyyy-MM-dd");
}

QString jsString(quint32 js)
{
    QTime time(0, 0);
    return QString("%1%2").arg(time.addMSecs(js / 10).toString("HH:mm:ss.zzz")).arg(js % 10);
}

QString ertString(quint32 js,quint16 ms)
{
    QTime time(0, 0);
    return QString("%1%2").arg(time.addMSecs(js / 10).toString("HH:mm:ss.zzz")).arg((js % 10 * 100) + (ms % 1000));
}

ProtocolTableModel::ProtocolTableModel(QObject *parent)
    : QAbstractTableModel(parent)
{

}

QString bidString(quint32 bid)
{
    QSettings settings;
    QString code = "BID/"+QString("%1").arg(qFromBigEndian(bid), 8, 16, QLatin1Char('0'));
    return settings.value(code, "").toString();
}
